################################## 
############ Preamble ############ 
################################## 

# set language to English
Sys.setenv(LANG = "en")

# clean up
rm(list = ls())

# Set working directory: please set your own
#setwd("~/Dropbox/JOP third submission/JOP replication/")

# Load necessary packages
library(tidyverse)
library(readstata13)

# Import dataset
controls_2 <- read.dta13("01_data/survey_data_2.dta")

# Make the plot
uncomfortable_controls_plot <-  controls_2 %>%
  filter(Removed != "fake") %>%
  filter(Model == "uncomfortable") %>%
  mutate(ci_lower_90 = coef - 1.645 * stderr) %>%
  mutate(ci_upper_90 = coef + 1.645 * stderr) %>%
  ggplot(aes(x = Removed, y = coef)) +
  geom_hline(aes(yintercept = 0), linetype = 2, color = "red") + 
  coord_flip( ) + 
  geom_linerange(aes(ymin = ci_lower, ymax = ci_upper), position = position_dodge(width = 0.75), size = 0.5) + 
  geom_linerange(aes(ymin = ci_lower_90, ymax = ci_upper_90), position = position_dodge(width = 0.75), size = 1) +
  geom_point(size = 1, position = position_dodge(width = 0.75) ) + 
  theme_minimal(base_size = 9) +
  theme_bw() +
  facet_wrap(FE~.) +
  labs(y = "Coefficient for interaction between voting for PP and use of voting booth as a predictor of signs of discomfort", x = "Control ommitted")
uncomfortable_controls_plot

ggsave("04_plots/figured8.png", plot = uncomfortable_controls_plot, width = 20, height = 15, units = "cm")